#ifndef COMMON_H_
#define COMMON_H_
#define DEFAULT_PORT	2749

#define BYTE			1
#define KBYTE			1024 * BYTE
#define MBYTE			1024 * KBYTE
#define MAX_INFO		4 * MBYTE /*MAXIMUM FILE SIZE*/

#define MAX_USER		64
#define MAX_PASS		64
#define MAX_PATH		256
#define MAX_ERROR		256
#define MAX_DOCS		400
#define MAX_FILE_SIZE	2048
#define MAX_SECTOR		20
#define MAX_LEVEL		20
#define MAX_SESSION		16
#define MAX_RSA_SESSION	256
#define RSA_STRING		5000
#define MAX_KEY			16

#include "../server/structures.h"
/* FOR OPTION DEFINITION */
typedef enum  
{
	SEND_FILE, LIST_FILES, GET_FILE, SET_PERMISSION
} RequestType;

typedef enum  
{
	ACK_OK, ACK_WARNING, ACK_ERROR
} MessageType;

typedef struct RequestPacket
{
	RequestType request;
	char fileName[MAX_PATH + 1]; /* Should be used to request a file from server*/
} RequestPacket;

typedef struct AuthPacket
{
	char user[MAX_USER + 1]; 			/* Travell's uncrypted */
	char password[MAX_RSA_SESSION]; 		/* Must be encrypted with the session key */
	char sessionKey[MAX_RSA_SESSION];	/* This must be encrypted with server's public key
										   and client private key*/
} AuthPacket;

typedef struct MessagePacket
{
	int response; /* What kind of ACK is: OK,Warning, error */
	char message[MAX_ERROR + 1];
} MessagePacket;

typedef struct ListPacket
{
	int amount;
	char documents[MAX_DOCS][MAX_TITLE];	
	
} ListPacket;

typedef struct ContentPacket
{
	char fileName[MAX_PATH];
	int fsize;
	char sector[MAX_SECTOR+1];
	char level[MAX_LEVEL+1];
	char sessionDecrypt[MAX_RSA_SESSION];	
	char data[MAX_FILE_SIZE];			/* The only thing that travells encrypted.
										It must be encrypted with the session key established*/
} ContentPacket;

typedef struct PermPacket
{
	RequestType request;
	char user[MAX_USER];
	char fileName[MAX_PATH];
	char alloweduser[MAX_USER];
	char sessionKey[MAX_RSA_SESSION];
} PermPacket;

#endif /*COMMON_H_*/
